<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片跟随鼠标移动</title>
    <style>
        body{
            background-color: black;
        }
        #aims {
            position: absolute;
            display: none;
            width: 30px;
        }
    </style>
</head>

<body>
    <img src="../images/aim.png" alt="" id="aims">
    <script>
        //设计图标跟随鼠标移动
        var aims = document.getElementById("aims");
        document.onmousemove = function (event) {
            var x = event.clientX;
            var y = event.clientY;
            aims.style.top = y - aims.height / 2 + 'px';
            aims.style.left = x - aims.width / 2 + 'px';
            aims.style.display = "block";
        }
    </script>
</body>

</html>